import 'package:flutter/material.dart';

import 'native_add.dart';

class MyRowWidget extends StatelessWidget {
  final Widget title;

  MyRowWidget(this.title);

  @override
  Widget build(BuildContext context) {
    return new Container(
        height: 56.0,
        padding: const EdgeInsets.symmetric(horizontal: 8),
        decoration: new BoxDecoration(color: Colors.blue[500]),
        child: new Row(children: <Widget>[
          new IconButton(
              icon: new Icon(Icons.menu),
              tooltip: 'Navigation menu',
              onPressed: null),
          new Expanded(child: title),
          new IconButton(
              icon: new Icon(Icons.search), tooltip: 'Search', onPressed: null)
        ]));
  }
}

class MyMaterialWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Material(
        child: new Column(
      children: [
        new MyRowWidget(
            new Text("title", style: Theme.of(context).primaryTextTheme.title)),
        new Expanded(child: new Center(child: new Text("hello , world!"))),
        new MyRowWidget(
            new Text("title", style: Theme.of(context).primaryTextTheme.title)),
        new Expanded(child: new Center(child: new Text("hello , world!")))
      ],
    ));
  }
}

class TutorialHome extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    //Scaffold是Material中主要的布局组件.
    return new Scaffold(
      appBar: new AppBar(
        leading: new IconButton(
          icon: new Icon(Icons.menu),
          tooltip: 'Navigation menu',
          onPressed: null,
        ),
        title: new Text('Example title,${nativeAdd(100, 99)}'),
        actions: <Widget>[
          new IconButton(
            icon: new Icon(Icons.search),
            tooltip: 'Search',
            onPressed: null,
          ),
        ],
      ),
      //body占屏幕的大部分
      body: new Center(
        child: new Text('Hello, world!'),
      ),
      floatingActionButton: new FloatingActionButton(
        tooltip: 'Add', // used by assistive technologies
        child: new Icon(Icons.add),
        onPressed: null,
      ),
    );
  }
}

class MyButton extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new GestureDetector(
      onTap: () {
        print('MyButton was tapped!');
      },
      child: new Container(
        height: 36.0,
        padding: const EdgeInsets.all(8.0),
        margin: const EdgeInsets.symmetric(horizontal: 8.0),
        decoration: new BoxDecoration(
          borderRadius: new BorderRadius.circular(5.0),
          color: Colors.lightGreen[500],
        ),
        child: new Center(
          child: new Text('Engage'),
        ),
      ),
    );
  }
}

class Counter extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => new _CounterState();
}

class _CounterState extends State<Counter> {
  int _counter = 0;

  _increment() => setState(() {
        _counter++;
      });

  @override
  Widget build(BuildContext context) {
    return new Row(children: [
      new RaisedButton(onPressed: _increment, child: Text('Increment'))
    ]);
  }
}
